package com.huawei.hwCloudJs.service.a;

import android.text.TextUtils;
import android.util.Log;
import com.huawei.hms.framework.network.util.HttpUtils;
import com.huawei.hwCloudJs.service.a.a.a;
import java.util.List;

public class c {
    private static final String a = "AuthUtils";

    private static boolean a(String str, String str2) {
        if (TextUtils.isEmpty(str2)) {
            return false;
        }
        int i;
        if (!str2.startsWith("*")) {
            boolean z = false;
        } else if (str2.length() > 1) {
            str2 = str2.substring(1);
            i = 1;
        } else {
            i = 1;
        }
        if (str2.endsWith("*")) {
            str2 = str2.substring(0, str2.length() - 1);
            int i2 = 1;
        } else {
            boolean z2 = false;
        }
        int indexOf = str.indexOf(str2);
        if (indexOf == -1) {
            return false;
        }
        if (indexOf > 0 && r0 == 0) {
            return false;
        }
        if ((str2.length() + indexOf) - 1 < str.length() - 1 && r3 == 0) {
            return false;
        }
        i = str.startsWith(HttpUtils.HTTP_PREFIX) ? 7 : str.startsWith("https://") ? 8 : 0;
        i = str.indexOf("/", i);
        return i == -1 || i > indexOf;
    }

    public static boolean a(String str, List<String> list, a aVar) {
        return a(aVar.c(), str) ? list.isEmpty() || (aVar.b() != null && aVar.b().containsAll(list)) : false;
    }

    public static boolean a(List<String> list, String str) {
        if (TextUtils.isEmpty(str) || list == null) {
            Log.e("jssdk", "isUrlValid error!");
            return false;
        }
        synchronized (list) {
            if (list.size() == 0) {
                Log.d(a, "urlList empty ,true");
                return false;
            }
            for (String a : list) {
                if (a(str, a)) {
                    Log.e("jssdk", "isUrlValid patternStr OK");
                    return true;
                }
            }
            Log.e("jssdk", "isUrlValid patternStr fail!");
            return false;
        }
    }
}
